package stack_queue

func NewMyStack2(size int) *MyStack2 {
	return &MyStack2{arr: make([]interface{}, size), index: 0, size: size}
}

type MyStack2 struct {
	size int
	index int
	arr []interface{}
}

func (s *MyStack2) Push(val int) {
	if s.index == s.size {
		panic("stack was fulled can't push !!!")
	}
	s.arr[s.index] = val
	s.index++
}

func (s *MyStack2) Pop() int {
	if s.index == 0 {
		panic("stack was empty can't pop !!!")
	}
	s.index--
	return s.arr[s.index].(int)
}

func (s *MyStack2) IsEmpty() bool {
	return s.index == 0
}